package com.eci.common.asset.custom;

import java.io.IOException;

import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
/**
 * 	全局日期（针对 java.sql.Date、java.sql.Time、java.sql.TimeStamp三种）
 * jackson反解析
 * */
public class CustomDateDeserializer {
	
	
	public static class TimestampDeserializer extends JsonDeserializer<Timestamp> {

		@Override
		public Timestamp deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
			
			return Timestamp.valueOf(p.getValueAsString());
		}

	}
	public static class SqlDateDeserializer extends JsonDeserializer<Date> {

		@Override
		public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
			
			return Date.valueOf(p.getValueAsString());
		}

	}
	

	public static class SqlTimeDeserializer extends JsonDeserializer<Time> {

		@Override
		public Time deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
			
			return Time.valueOf(p.getValueAsString());
		}

	}
	
}
